home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 October
/
CHIP Turkiye Ekim 2000.iso
/
prog
/
naps
/
04
/
setup.exe
/
Gnucleus
/
GnuControl.h
< prev
next >
Wrap
C/C++ Source or Header
|
2000-07-15
|
4KB
|
159 lines
#if !defined(AFX_GNUCONTROL_H__60210B40_1340_11D4_ACF2_00A0CC533D52__INCLUDED_)
#define AFX_GNUCONTROL_H__60210B40_1340_11D4_ACF2_00A0CC533D52__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// GnuControl.h : header file
//
#include "packet.h" // Packet type definitions
#include "GnuHash.h"
#pragma warning (disable : 4786)
#include <string>
#include <list>
#include <map>
class CGnucleusDoc;
class CGnuSock;
class CGnuTransfer;
struct CompareGuids {
bool operator () (const GUID& left, const GUID& right) const
{
return (::memcmp (&left, &right, sizeof(GUID)) < 0);
}
};
typedef struct
{
CGnuSock * ConnectedSock;
CString SearchString;
GUID ClientGuid;
GUID Origin;
IP Host;
WORD localPort;
bool bIsMatch;
}SearchQueryItem, *LPSearchQueryItem;
/////////////////////////////////////////////////////////////////////////////
// CGnuControl command target
class CGnuControl : public CAsyncSocket
{
DECLARE_DYNCREATE(CGnuControl)
// Attributes
public:
// Operations
public:
CGnuControl();
CGnuControl(CGnucleusDoc *DocLink);
virtual ~CGnuControl();
void StartListening();
BOOL AddNode(CString Host, CString Port);
void RemoveNode(CString Host, CString Port);
CGnuSock* GetNode(CString);
void AddTransfer(QueryItem File, SOCKET sock = NULL);
void RemoveTransfer(int row, char type);
CGnuTransfer* GetTransfer(int row, char type);
void NewPushRequest(QueryItem File);
DWORD GetHostCount();
// Pass packets to all other nodes, special routing here also
void Pass_Raw(CGnuSock *, byte *, int);
void Broadcast_Ping(packet_Ping *, int, CGnuSock *);
void Broadcast_Query(packet_Query *, int, CGnuSock *);
void Route_Pong(packet_Pong *, int, key_data *);
void Route_QueryReply(packet_QueryReply *, int, key_data *);
void Route_Push(packet_Push *, int, key_data *);
int RunningThreads;
// Localhost info
CString localHost;
DWORD localPort;
// Our client's 128bit ID
GUID ClientGUID;
typedef std::map <GUID, CGnuSock*, CompareGuids> GuidHash;
GuidHash m_cache;
CGnuHash HashClientTable; // Stores client values from Query Replies
// CGnuHash HashTable; // Stores GUIDs from Pings and Queries
CGnuHash SendTable; // Stores GUIDs of sent packets
// Statistics
DWORD BytesIn;
DWORD BytesOut;
double long totalPings, totalPongs,
totalPushes, totalUnknowns,
totalQueries, totalQueryReplies,
totalTTLs, totalTTLsBig,
totalHops, totalHopsBig;
// Pointer to the document
CGnucleusDoc *Doc;
// Overrides
public:
DWORD m_dwTotalBytesIn;
DWORD m_dwTotalBytesOut;
DWORD m_dwBytesPerSecIn;
DWORD m_dwBytesPerSecOut;
void OnTimer();
bool PopQueryFromQueue(SearchQueryItem & _search_item);
void PushQueryToQueue(CGnuSock * _lp_sock);
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGnuControl)
public:
virtual void OnAccept( int nErrorCode );
//}}AFX_VIRTUAL
// Generated message map functions
//{{AFX_MSG(CGnuControl)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
// Implementation
protected:
UINT QueriesSearchThread();
static UINT staticQueriesSearchThread(LPVOID);
CWinThread * m_QueriesSearchThreadHandle;
CCriticalSection m_QueryListCriticalSection;
CEvent m_EventQueriesEND;
CEvent m_EventQueriesWaiting;
std::list<SearchQueryItem> m_SearchQueries;
void m_Initialize (void);
CGnuSock *NodeList;
CGnuTransfer *TransferList;
std::list<QueryItem> m_PushRequests;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_GNUCONTROL_H__60210B40_1340_11D4_ACF2_00A0CC533D52__INCLUDED_)